package zhongbo.java.air.flightpath.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.listener.PatternTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.listener.Topic;
import zhongbo.java.air.flightpath.listener.RedisSubChanelListener;
import zhongbo.java.air.flightpath.listener.RedisSubscribeLogChanelListener;

@Configuration
@Slf4j
public class RedisListenerConfig {

    public static String LOG_CHANEL = "log_channel";
    public static String INJEST_FLIGHT_PATH = "injest_flight_path_tang_guo_zheng";
    public static String LIVE_FLIGHT_PATH_TANG_GUO_ZHENG = "live_flight_path_tang_guo_zheng";

    /**
     * 配置redis 监听容器
     */

    @Autowired
    public void configListener(RedisMessageListenerContainer listenerContainer,
                               RedisSubscribeLogChanelListener logChanelListener,
                               RedisSubChanelListener redisSubChanelListener){
        Topic logTopic = new PatternTopic(LOG_CHANEL);
        listenerContainer.addMessageListener(logChanelListener,logTopic);
        listenerContainer.addMessageListener(redisSubChanelListener,new PatternTopic(INJEST_FLIGHT_PATH));

    }

}
